package com.atguigu.spring.dao.impl;

import com.atguigu.spring.dao.api.TigerDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class TigerDaoImpl implements TigerDao {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Override
    public void updateNameAndSalary01(Integer tigerId, String tigerName, Double tigerSalary) {
        String sql = "update t_tiger set tiger_name=?, tiger_salary=? where tiger_id=?";
        jdbcTemplate.update(sql, tigerName, tigerSalary, tigerId);
    }

    @Override
    public void updateNameAndSalary02(Integer tigerId, String tigerName, Double tigerSalary) {
        String sql = "update t_tiger set tiger_name=?, tiger_salary=? where tiger_id=?";
        jdbcTemplate.update(sql, tigerName, tigerSalary, tigerId);
    }

    @Override
    public Double selectSalaryById(Integer tigerId) {
        String sql = "select tiger_salary from t_tiger where tiger_id=?";
        return jdbcTemplate.queryForObject(sql, Double.class, tigerId);
    }

    @Override
    public void updateTigerSalaryById(Integer tigerId, Double tigerSalary) {
        String sql = "update t_tiger set tiger_salary=? where tiger_id=?";
        jdbcTemplate.update(sql, tigerSalary, tigerId);
    }

    @Override
    public void updateNameById01(Integer tigerId, String tigerName) {
        String sql = "update t_tiger set tiger_name=? where tiger_id=?";
        jdbcTemplate.update(sql, tigerName, tigerId);
    }

    @Override
    public void updateNameById02(Integer tigerId, String tigerName) {
        String sql = "update t_t2iger set tiger_name=? where tiger_id=?";
        jdbcTemplate.update(sql, tigerName, tigerId);
    }
}
